import handleArr from './index'

let reducer = (
  state = {
    ...handleArr.state,
  },
  action: { type: string }
) => {
  let newState = JSON.parse(JSON.stringify(state))

  // handleArr.actions[action.type](newState, action)

  for (let key in handleArr.actionNames) {
    // 判断是不是相等
    if (handleArr.actionNames[key] === action.type) {
      handleArr.actions[action.type](newState, action)
      break
    }
  }
  return newState
}

export default reducer
